#ifndef PRPDFEATURE_H
#define PRPDFEATURE_H

#include <QWidget>
#include <QTableWidget>
#include <QGroupBox>
#include <QVBoxLayout>
#include "tabframe/mapinfo/mapinfotab.h"
#include "prps/prpdspectrum.h"

/**
 * @brief PRPD特性组件
 * 处理相位分辨局部放电图谱相关的数据显示
 */
class PRPDFeature : public QObject, public virtual IMapInfoFeature, public virtual IAmplitudeFeature
{
    Q_OBJECT
public:
    explicit PRPDFeature(QObject* parent = nullptr);
    virtual ~PRPDFeature();

    // 从IMapInfoFeature接口
    QWidget* initUI(QWidget* parent) override;
    void loadFromSpectrum(DataSpecificationGW::Spectrum* spectrum) override;

    // 从IAmplitudeFeature接口
    void setAmplitudeUnit(uint8_t unit) override;
    void setAmplitudeLowerLimit(float lowerLimit) override;
    void setAmplitudeUpperLimit(float upperLimit) override;

    // PRPD特有的方法
    void setQuantizedAmplitude(int32_t amp);
    void setPhaseWindowCount(int32_t count);
    void setFrequencyPeriod(int32_t period);
    void setPRPDData(const QByteArray& data);
    
    // 基础信息相关方法
    void setDataTypeCode(uint8_t code);
    void setDataLength(int32_t length);
    void setCreateTime(const QString& time);
    void setChartProperty(const DataSpecificationGW::SpectrumCharacter& property);
    void setDeviceName(const QString& name);
    void setDeviceCode(const QString& code);
    void setMeasurementName(const QString& name);
    void setMeasurementCode(const QString& code);
    void setChannelFlag(int64_t flag);
    void setDataType(uint8_t type);
    void setReservedData(const QByteArray& data);

private:
    QTableWidget* m_dataTable;
    QGroupBox* m_groupBox;
    QTableWidgetItem* createTableWidgetItem(const QString& text);

    // 数据成员
    uint8_t m_amplitudeUnit;
    float m_amplitudeLowerLimit;
    float m_amplitudeUpperLimit;
    int32_t m_quantizedAmplitude;
    int32_t m_phaseWindowCount;
    int32_t m_frequencyPeriod;
    QByteArray m_prpdData;
    
    // 基础信息成员变量
    uint8_t m_dataTypeCode;
    int32_t m_dataLength;
    QString m_createTime;
    DataSpecificationGW::SpectrumCharacter m_chartProperty;
    QString m_deviceName;
    QString m_deviceCode;
    QString m_measurementName;
    QString m_measurementCode;
    int64_t m_channelFlag;
    uint8_t m_dataType;
    QByteArray m_reservedData;

    // 更新表格显示
    void updateTable();
};

#endif // PRPDFEATURE_H 
